package com.shengwei.truck.driver.third_sdk.jpush;
import android.content.Intent;
import android.util.Log;

import com.huawei.hms.push.HmsMessageService;
import com.huawei.hms.push.RemoteMessage;
import com.shengwei.truck.driver.utils.MyLogCat;

import java.util.Arrays;

import cn.jpush.android.service.PluginHuaweiPlatformsService;

public class MyHuaweiPlatformService extends HmsMessageService {
    final PluginHuaweiPlatformsService service = new PluginHuaweiPlatformsService();
    String TAG = "MyHuaweiPlatformService";
    @Override
    public void onNewToken(String s) {
        service.onNewToken(s);
    }

    @Override
    public void onMessageReceived(RemoteMessage message) {
        service.onMessageReceived(message);
        MyLogCat.i(TAG,"onMessageReceived");

        Log.i(TAG, "getCollapseKey: " + message.getCollapseKey()
                + "\n getData: " + message.getData()
                + "\n getFrom: " + message.getFrom()
                + "\n getTo: " + message.getTo()
                + "\n getMessageId: " + message.getMessageId()
                + "\n getMessageType: " + message.getMessageType()
                + "\n getSendTime: " + message.getSentTime()
                + "\n getTtl: " + message.getTtl()
                + "\n getSendMode: " + message.getSendMode()
                + "\n getReceiptMode: " + message.getReceiptMode()
                + "\n getOriginalUrgency: " + message.getOriginalUrgency()
                + "\n getUrgency: " + message.getUrgency()
                + "\n getToken: " + message.getToken());

        // getBody() Obtains the displayed content of a message
        // getTitle() Obtains the title of a message
        // getTitleLocalizationKey() Obtains the key of the displayed title of a notification message
        // getTitleLocalizationArgs() Obtains variable parameters of the displayed title of a message
        // getBodyLocalizationKey() Obtains the key of the displayed content of a message
        // getBodyLocalizationArgs() Obtains variable parameters of the displayed content of a message
        // getIcon() Obtains icons from a message
        // getSound() Obtains the sound from a message
        // getTag() Obtains the tag from a message for message overwriting
        // getColor() Obtains the colors of icons in a message
        // getClickAction() Obtains actions triggered by message tapping
        // getChannelId() Obtains IDs of channels that support the display of messages
        // getImageUrl() Obtains the image URL from a message
        // getLink() Obtains the URL to be accessed from a message
        // getNotifyId() Obtains the unique ID of a message

        RemoteMessage.Notification notification = message.getNotification();
        if (notification != null) {
            Log.i(TAG, "\n getTitle: " + notification.getTitle()
                    + "\n getTitleLocalizationKey: " + notification.getTitleLocalizationKey()
                    + "\n getTitleLocalizationArgs: " + Arrays.toString(notification.getTitleLocalizationArgs())
                    + "\n getBody: " + notification.getBody()
                    + "\n getBodyLocalizationKey: " + notification.getBodyLocalizationKey()
                    + "\n getBodyLocalizationArgs: " + Arrays.toString(notification.getBodyLocalizationArgs())
                    + "\n getIcon: " + notification.getIcon()
                    + "\n getImageUrl: " + notification.getImageUrl()
                    + "\n getSound: " + notification.getSound()
                    + "\n getTag: " + notification.getTag()
                    + "\n getColor: " + notification.getColor()
                    + "\n getClickAction: " + notification.getClickAction()
                    + "\n getIntentUri: " + notification.getIntentUri()
                    + "\n getChannelId: " + notification.getChannelId()
                    + "\n getLink: " + notification.getLink()
                    + "\n getNotifyId: " + notification.getNotifyId()
                    + "\n isDefaultLight: " + notification.isDefaultLight()
                    + "\n isDefaultSound: " + notification.isDefaultSound()
                    + "\n isDefaultVibrate: " + notification.isDefaultVibrate()
                    + "\n getWhen: " + notification.getWhen()
                    + "\n getLightSettings: " + Arrays.toString(notification.getLightSettings())
                    + "\n isLocalOnly: " + notification.isLocalOnly()
                    + "\n getBadgeNumber: " + notification.getBadgeNumber()
                    + "\n isAutoCancel: " + notification.isAutoCancel()
                    + "\n getImportance: " + notification.getImportance()
                    + "\n getTicker: " + notification.getTicker()
                    + "\n getVibrateConfig: " + Arrays.toString(notification.getVibrateConfig())
                    + "\n getVisibility: " + notification.getVisibility());
        }

        Intent intent = new Intent();
        intent.putExtra("method", "onMessageReceived");
        intent.putExtra("msg", "onMessageReceived called, message id:" + message.getMessageId() + ", payload data:"
                + message.getData());
    }

    @Override
    public void onMessageSent(String s) {
        service.onMessageSent(s);
    }

    @Override
    public void onSendError(String s, Exception e) {
        service.onSendError(s,e);
    }

    @Override
    public void onDeletedMessages() {
        service.onDeletedMessages();
    }
}
